import { defineStore } from 'pinia';
import { PiniaEnum } from './store-naspace';
export const useTsetStore = defineStore(PiniaEnum.Tset, {
    state: () => {
        return {
            current: 1,
            piniaName: 'pinia',
            PiniaObj: {
                age: 10
            }
        }
    },
    //类似于computed 可以帮我们去修饰我们的值
    getters: {
        // 使用箭头函数不能使用this this指向已经改变指向undefined 修改值请用state(主要作用类似于computed 数据修饰并且有缓存)
        newName: (state) => state.piniaName + '---getters',
        newAge: function():number {
            return this.PiniaObj.age
        },
        addGetter(): number {
            return this.current + this.PiniaObj.age
        }
    },
     //可以操作异步 和 同步提交state
    actions: {
        setCurrent() {
            this.current = this.current + 10
        }
    }
});

